from drf_haystack.viewsets import HaystackViewSet
from .indexser import HouseListingIndexSerializer
from rest_framework.response import Response

class HouseListingSearchViewSet(HaystackViewSet):
    index_models = [HouseListing]
    serializer_class = HouseListingIndexSerializer

    def list(self, request, *args, **kwargs):
        try:
            return super().list(request, *args, **kwargs)
        except Exception as e:
            return Response({
                'error': str(e),
                'status': 500
            }, status=500) 